unit UDMFAT;

interface

uses
  SysUtils, Classes, Dialogs, Messages, DB, ADODB;

Const CTDB_FILE_CONFIG     = 'CRWeb.udl';
      CTDirTXT_ARQ_RETORNO_TIPO1 = 'C:\CRWEB\SISTEMAS\TXT_ARQ-RETORNO_TIPO1\';
      CTDirTXT_ARQ_RETORNO_TIPO2 = 'C:\CRWEB\SISTEMAS\TXT_ARQ-RETORNO_TIPO2\';
      CTDirTXT_ARQ_RETORNO_TIPO3 = 'C:\CRWEB\SISTEMAS\TXT_ARQ-RETORNO_TIPO3\';

type
  TDMFAT = class(TDataModule)
    ADOConnSA: TADOConnection;
    ADOQryMain: TADOQuery;
  private
    { Private declarations }

  public
    { Public declarations }
    function TestConnection: Boolean;
    function ValidateConnection(sValue: String = ''): Boolean;
  end;

var
  DMFAT: TDMFAT;

implementation

{$R *.dfm}

{ TDataModule1 }

function TDMFAT.TestConnection: Boolean;
  var
    ADOQryTestConn: TADOQuery;
    bResponse: Boolean;
begin
  bResponse := False;
  try
    try
      ADOQryTestConn := TADOQuery.Create(Self);
      ADOQryTestConn.Connection := ADOConnSA;

      ADOQryTestConn.Close;
      ADOQryTestConn.SQL.Clear;
      ADOQryTestConn.SQL.Text := 'SELECT USU_ID FROM Usuario WHERE (USU_ID <= 5)';
      ADOQryTestConn.Open;
      if(ADOQryTestConn.RecordCount > 0) then
      begin
        Result := True;
      end
      else
      begin
      end;
    except
      On Erro: Exception do
      begin
        ShowMessage('ERRO : [TDMFAT].[TestConnection] ' + #13 + #13 + #13 + 'Msg.: ' + Erro.Message);
      end;
    end; // fim try except
  finally
    FreeAndNil(ADOQryTestConn);
  end; // fim try finally
end;

function TDMFAT.ValidateConnection(sValue: String = ''): Boolean;
  var
    PathFileConfig: String;
begin

end;

end.
